<?php
/**
 * Simple Light PHP Framework
 *
 * @copyright Marc PEPIN 2012
 * @author Marc PEPIN
 *
 */

defined('SLP_ROOT') or die("You've not access to this page");

/** 
* Simple Light Php Framework Database Class
* @package		Slp
* @author    	Marc PEPIN
*/ 

class Slp_Config {
	
	/**
	* Config data
	* @var array
	*/
	
	private $vars = array();

	
	/**
	*	Load configuration File
	*	@param string
	*	@return void
	*/
	
	public function load($_config_) {
	
		$file = SLP_ROOT.'/application/config/'.$_config_.'.php';
		if (!is_file($file))
			return false;
		include($file);
	
		if (isset(${$_config_}))
			$this->vars[$_config_] = ${$_config_};
			
		return true; 
	}
	
	
	/**
	* Get Config name
	* @param string
	* @param string 
	*/
	
	public function get($name, $config = NULL) {
		if (!$config) {
			foreach ($this->vars as $vars) {
				foreach ($vars as $key => $val) {
				if ($key == $name)
					return $val;	
				}
			}
		}
		else {
			foreach ($this->vars[$config] as $key => $val) {
				if ($key == $name)
					return $val;	
				}
		}
		return NULL;
	}
}

?>